/**
 * Created by KingKong on 2017/8/9.
 */
import {AbstractControl, ValidatorFn} from '@angular/forms';

/**
 * 自定义验证规则：与同一表单其他项比较
 * */
export function customizeEqualToValidator(equalToField: string, key: string): ValidatorFn {
  return (control: AbstractControl): { [key: string]: any } => {
    const equalField = control.parent.get(equalToField);
    return control.value === equalField.value ? null : {[key]: true};
  };
}
